Class HCC.DT.HCC2HL72.InPatientUpd Extends Ens.DataTransformDTL [ DependsOn = (EnsLib.EDI.XML.Document, EnsLib.HL7.Message) ]
{

Parameter IGNOREMISSINGSOURCE = 1;

Parameter REPORTERRORS = 1;

Parameter TREATEMPTYREPEATINGFIELDASNULL = 0;

XData DTL [ XMLNamespace = "http://www.intersystems.com/dtl" ]
{
<transform sourceClass='EnsLib.EDI.XML.Document' targetClass='EnsLib.HL7.Message' sourceDocType='PRPA_IN400002UV:PRPA_IN400002UV' targetDocType='2.5.1:ADT_A01' create='new' language='objectscript' >
<assign value='source.{id().extension}' property='target.{MSH:MessageControlID}' action='set' />
<assign value='source.{creationTime().value}' property='target.{MSH:DateTimeOfMessage.Time}' action='set' />
<assign value='"ADT"' property='target.{MSH:MessageType.MessageCode}' action='set' />
<assign value='"A01"' property='target.{MSH:MessageType.TriggerEvent}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().subject().patient().id().item().extension}' property='target.{PID:PatientID.IDNumber}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().subject().patient().choice.patientPerson().id.item().extension}' property='target.{PID:PatientIdentifierList(1).IDNumber}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().subject().patient().choice.patientPerson().name()},"//s:item/s:part/@value")' property='target.{PID:PatientName(1)}' action='set' />
<foreach property='source.{controlActProcess(k1).subject().encounterEvent().reason()}' key='k1' >
<assign value='source.{controlActProcess().subject().encounterEvent().reason(k1).observationDx().value().displayName.value}' property='target.{DG1(k1):DiagnosisDescription}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().reason(k1).observationDx().author().assignedEntity().id().item().extension}' property='target.{DG1(k1):DiagnosingClinician(1).IDNumber}' action='set' />
</foreach>
<assign value='source.{controlActProcess().subject().encounterEvent().admissionReferralSourceCode.displayName.value}' property='target.{IN1grp(1).IN1:InsuranceCompanyName(1)}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().code().displayName.value}' property='target.{EVN:EventTypeCode}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().effectiveTime().low.value}' property='target.{EVN:EventOccurred.Time}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().reasonCode.item().originalText.value}' property='target.{EVN:EventReasonCode}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().location().serviceDeliveryLocation().serviceProviderOrganization.id().item().extension}' property='target.{PV1:ServicingFacility}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location().serviceDeliveryLocation().location.locatedEntityHasParts().locatedPlace().locatedEntityHasParts().locatedPlace().name},"//s:item/s:part/@value")' property='target.{PV1:AssignedPatientLocation.Room}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location().serviceDeliveryLocation().location.locatedEntityHasParts().locatedPlace().locatedEntityHasParts().locatedPlace().locatedEntityHasParts().locatedPlace().name},"//s:item/s:part/@value")' property='target.{PV1:AssignedPatientLocation.Bed}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location().serviceDeliveryLocation().location.locatedEntityHasParts().locatedPlace().name},"//s:item/s:part/@value")' property='target.{PV1:AssignedPatientLocation.Facility}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location().serviceDeliveryLocation().location.name},"//s:item/s:part/@value")' property='target.{PV1:AssignedPatientLocation.Floor}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().lengthOfStayQuantity.value}' property='target.{EVN:RecordedDateTime.Time}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().lengthOfStayQuantity.unit}' property='target.{EVN:RecordedDateTime.DegreeofPrecision}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().id().item(1).extension}' property='target.{PID:AlternatePatientIDPID(1).IDNumber}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().admitter.assignedPerson().id.item().extension}' property='target.{PV1:AttendingDoctor(1).IDNumber}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().admitter.assignedPerson().assignedPerson.name()},"//s:item/s:part/@value")' property='target.{PV1:AttendingDoctor().FamilyName}' action='set' />
</transform>
}

}
